﻿using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class DamageText : MonoBehaviour
{
    public TextMeshProUGUI text;

    // Use this for initialization
    void Start()
    {
        //StartCoroutine(ShowDamage());
        Destroy(gameObject,0.5f);
        
    }
    private void Update()
    {
        transform.position += new Vector3(0, 0.05f, 0);
        transform.rotation = Camera.main.transform.rotation;
    }
    IEnumerator ShowDamage()
    {
        Debug.Log(text.text);
        Color c = text.color;
        while (c.a > 0)
        {
            c.a -= 0.05f  *  255;
           
            transform.position += new Vector3(0, 0.05f, 0);
            yield return new WaitForSeconds(0.05f);
        }
        Destroy(gameObject);
    }
}
